/**
 * 
 */
package com.mes.check.domain;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.context.annotation.Lazy;

import com.mes.basicdata.domain.Dept;
import com.mes.basicdata.domain.Employee;
import com.mes.common.domain.BasicModel;
import com.mes.task.domain.OperationTask;

/**
 * <p>
 * 不合格品审理单表头信息
 * </p>
 */
@Entity()
@Table(name = "M_DEFECTJUDGEHEADER")
@BatchSize(size = 20)
@Lazy(value = true)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class DefectJudge extends BasicModel implements java.io.Serializable {

	/**
	 * 返工
	 */
	public static final String JUDGE_RESULT_REWORK = "4";
	/**
	 * 让步
	 */
	public static final String JUDGE_RESULT_REPAIR = "5";
	/**
	 * 报废
	 */
	public static final String JUDGE_RESULT_REJECT = "8";
	/**
	 * 建议返修
	 */
	public static final String JUDGE_RESULT_ADVISE_REWORK = "20";
	/**
	 * 建议让步
	 */
	public static final String JUDGE_RESULT_ADVISE_REPAIR = "21";
	/**
	 * 建议成批性报废
	 */
	public static final String JUDGE_RESULT_ADVISE_REJECT = "22";

	public static final int JUDGE_BILLSTATE_CREATED = 0; //　已创建
	public static final int JUDGE_BILLSTATE_UNCLOSED = 9; // 未结案
	public static final int JUDGE_BILLSTATE_CLOSED = 10; // 已结案
	
	
	@Id
	@GenericGenerator(name = "uniqueId", strategy = "assigned")
	@Column(name = "DEFECTJUDGEUID")
	protected String uniqueId;

	@Column(name = "DEFECTJUDGEID", length = 50)
	protected String defectJudgeId;

	/**
	 * 复杂对象映射--Task task
	 */
	@Column(name = "TASKUID", length = 50)
	protected String taskUid;
	
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TASKUID", insertable = false, updatable = false)
//	@NotFound(action = NotFoundAction.IGNORE)  
	protected OperationTask operationTask;

	// 送审数
	@Column(name = "SUBMITQTY", length = 50)
	protected Float submitQty;
	
	// 不合格数
	@Column(name = "DEFECTQTY", length = 50)
	protected Float defectQty;

	// 本批数量
	@Column(name = "PLANQTY", length = 50)
	protected Float planQty;
	
	// 生产批数
	@Column(name = "BATCHCOUNT", length = 50)
	protected Float batchCount;
	
	@Column(name = "JUDGESTATE", length = 50)
	protected Integer judgeBillState;

	/**
	 * 复杂对象映射--Employee judger
	 */
	@Column(name = "JUDGER", length = 50)
	protected String judgerUid;
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "JUDGER", insertable = false, updatable = false)
	protected Employee judger;

	/**
	 * 复杂对象映射--Employee checker
	 */
	@Column(name = "CHECKER", length = 50)
	protected String checkerUid;
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CHECKER", insertable = false, updatable = false)
	protected Employee checker;

	@Column(name = "CHECKTIME", length = 50)
	protected Date checkTime;

	/**
	 * 复杂对象映射--Dept dept
	 */
	@Column(name = "DEPTID", length = 50)
	protected String masterShopUid;
	
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "DEPTID", insertable = false, updatable = false)
	protected Dept masterShop;

	@Column(name = "ATTATCHREF", length = 50)
	protected String attatchRef;

	// protected String version;
	@Column(name = "ISINEFFECT", length = 50)
	protected Boolean isInEffect;

	@Column(name = "BILLNUMBER", length = 50)
	protected String billNumber;

	// 关联的检验单唯一号，记录该审理单审理内容来自哪些检验单
	@Column(name = "CHECKUIDS", length = 50)
	protected String checkBillUids;
	
	/**
	 * 复杂对象映射--Check Check
	 */
	@Column(name = "SUBMITCHECKUID", length = 50)
	protected String submitCheckBillUid;
	
	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "SUBMITCHECKUID", insertable = false, updatable = false)
	protected CheckBill checkBill;

	@Column(name = "JUDGETIME", length = 50)
	protected Date judgeTime;

	@Column(name = "VERSION", length = 50)
	protected String versionId;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "defectJudge")
	public List<DefectJudgeDetail> defectJudgeDetails;

	// 是否成批性报废
	@Column(name = "ISALLBATCH")
	protected Boolean isBulkReject;
	
	// 成批性报废审理签字
	@Column(name = "TEXT2")
	protected String bulkRejectJudgerName;
	
	// 成批性报废审理签字
	@Column(name = "DATE1")
	protected String bulkRejectJudgeSignDate;
		
	// 成批性报废审理意见
	@Column(name = "TEXT1")
	protected String bulkRejectJudgeMind;
	
	
	public DefectJudge() {
	}

	public String getUuid() {
		return uniqueId;
	}

	public void setUuid(String uuid) {
		this.uniqueId = uuid;
	}

	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}

	/**
	 * 获取缺陷审理表编号。
	 * 
	 * @return the defectJudgeId
	 */
	public String getDefectJudgeId() {
		return defectJudgeId;
	}

	/**
	 * 设置缺陷审理表编号。
	 * 
	 * @param defectJudgeId
	 */
	public void setDefectJudgeId(String defectJudgeId) {
		this.defectJudgeId = defectJudgeId;
	}

	/**
	 * 获取任务编号。
	 * 
	 * @return the taskUid
	 */
	public String getTaskUid() {
		return taskUid;
	}

	/**
	 * 设置任务编号。
	 * 
	 * @param taskUid
	 *            the taskUid to set
	 */
	public void setTaskUid(String taskUid) {
		this.taskUid = taskUid;
	}

	/**
	 * 获取操作任务。
	 * 
	 * @return the operationTask
	 */
	public OperationTask getOperationTask() {
		return operationTask;
	}

	/**
	 * 设置操作任务。
	 * 
	 * @param operationTask
	 *            the operationTask to set
	 */
	public void setOperationTask(OperationTask operationTask) {
		this.operationTask = operationTask;
	}

	/**
	 * 获取提交数量。
	 * 
	 * @return the submitQty
	 */
	public Float getSubmitQty() {
		return submitQty;
	}

	/**
	 * 设置提交数量。
	 * 
	 * @param submitQty
	 *            the submitQty to set
	 */
	public void setSubmitQty(Float submitQty) {
		this.submitQty = submitQty;
	}

	/**
	 * 获取不合格数量。
	 * 
	 * @return the defectQty
	 */
	public Float getDefectQty() {
		return defectQty;
	}

	/**
	 * 设置不合格数量。
	 * 
	 * @param defectQty
	 */
	public void setDefectQty(Float defectQty) {
		this.defectQty = defectQty;
	}

	/**
	 * 获取审理状态。
	 * 
	 * @return the judgeBillState
	 */
	public Integer getJudgeBillState() {
		return judgeBillState;
	}

	/**
	 * 设置审理状态。
	 * 
	 * @param judgeBillState
	 */
	public void setJudgeBillState(Integer judgeBillState) {
		this.judgeBillState = judgeBillState;
	}

	/**
	 * 获取审理者编号。
	 * 
	 * @return the judgerUid
	 */
	public String getJudgerUid() {
		return judgerUid;
	}

	/**
	 * 设置审理者编号。
	 * 
	 * @param judgerUid
	 */
	public void setJudgerUid(String judgerUid) {
		this.judgerUid = judgerUid;
	}

	/**
	 * 获取审理者。
	 * 
	 * @return the judger
	 */
	public Employee getJudger() {
		return judger;
	}

	/**
	 * 设置审理者。
	 * 
	 * @param judger
	 *            the judger to set
	 */
	public void setJudger(Employee judger) {
		this.judger = judger;
	}

	/**
	 * 获取检验员编号。
	 * 
	 * @return the checkerUid
	 */
	public String getCheckerUid() {
		return checkerUid;
	}

	/**
	 * 设置检验员编号。
	 * 
	 * @param checkerUid
	 *            the checkerUid to set
	 */
	public void setCheckerUid(String checkerUid) {
		this.checkerUid = checkerUid;
	}

	/**
	 * 获取检验员。
	 * 
	 * @return the checker
	 */
	public Employee getChecker() {
		return checker;
	}

	/**
	 * 设置检验员。
	 * 
	 * @param checker
	 *            the checker to set
	 */
	public void setChecker(Employee checker) {
		this.checker = checker;
	}

	/**
	 * 获取检验时间。
	 * 
	 * @return the checkTime
	 */
	public Date getCheckTime() {
		return checkTime;
	}

	/**
	 * 设置检验时间。
	 * 
	 * @param checkTime
	 *            the checkTime to set
	 */
	public void setCheckTime(Date checkTime) {
		this.checkTime = checkTime;
	}

	/**
	 * 获取主制车间编号。
	 * 
	 * @return the masterShopUid
	 */
	public String getMasterShopUid() {
		return masterShopUid;
	}

	/**
	 * 设置主制车间编号。
	 * 
	 * @param masterShopUid
	 *            the masterShopUid to set
	 */
	public void setMasterShopUid(String masterShopUid) {
		this.masterShopUid = masterShopUid;
	}

	/**
	 * 获取主制车间。
	 * 
	 * @return the masterShop
	 */
	public Dept getMasterShop() {
		return masterShop;
	}

	/**
	 * 设置主制车间。
	 * 
	 * @param masterShop
	 *            the masterShop to set
	 */
	public void setMasterShop(Dept masterShop) {
		this.masterShop = masterShop;
	}

	/**
	 * 获取关联文档名称。
	 * 
	 * @return the attatchRef
	 */
	public String getAttatchRef() {
		return attatchRef;
	}

	/**
	 * 设置关联文档名称。
	 * 
	 * @param attatchRef
	 *            the attatchRef to set
	 */
	public void setAttatchRef(String attatchRef) {
		this.attatchRef = attatchRef;
	}

	/**
	 * 获取版本信息。
	 * 
	 * @return the version
	 */
	 public String getVersionId() {
	 return versionId;
	 }

	/**
	 * 设置版本信息。
	 * 
	 * @param versionId
	 *            the versionId to set
	 */
	 public void setVersionId(String versionId) {
	 this.versionId = versionId;
	 }

	/**
	 * 获取有效状态。
	 * 
	 * @return the isInEffect
	 */
	public Boolean getIsInEffect() {
		return isInEffect;
	}

	/**
	 * 设置有效状态。
	 * 
	 * @param isInEffect
	 *            the isInEffect to set
	 */
	public void setIsInEffect(Boolean isInEffect) {
		this.isInEffect = isInEffect;
	}

	/**
	 * 获取表单号
	 * 
	 * @return the billNumber
	 */
	public String getBillNumber() {
		return billNumber;
	}

	/**
	 * 设置表单号。
	 * 
	 * @param billNumber
	 *            the billNumber to set
	 */
	public void setBillNumber(String billNumber) {
		this.billNumber = billNumber;
	}

	/**
	 * 获取提交检验编号。
	 * 
	 * @return the submitCheckBillUid
	 */
	public String getSubmitCheckBillUid() {
		return submitCheckBillUid;
	}

	/**
	 * 设置提交检验编号。
	 * 
	 * @param submitCheckUid
	 *            the submitCheckUid to set
	 */
	public void setSubmitCheckBillUid(String submitCheckBillUid) {
		this.submitCheckBillUid = submitCheckBillUid;
	}

	/**
	 * 获取检验表头。
	 * 
	 * @return the CheckBill
	 */
	public CheckBill getCheckBill() {
		return checkBill;
	}

	/**
	 * 设置检验表头。
	 * 
	 * @param CheckBill
	 *            the Check to set
	 */
	public void setCheckBill(CheckBill checkBill) {
		this.checkBill = checkBill;
	}

	/**
	 * 获取创建者。
	 * 
	 * @return the creator
	 */
	public Employee getCreator() {
		return creator;
	}

	/**
	 * 设置创建者。
	 * 
	 * @param creator
	 *            the creator to set
	 */
	public void setCreator(Employee creator) {
		this.creator = creator;
	}

	/**
	 * 获取审理时间。
	 * 
	 * @return the judgeTime
	 */
	public Date getJudgeTime() {
		return judgeTime;
	}

	/**
	 * 设置审理时间。
	 * 
	 * @param judgeTime
	 *            the judgeTime to set
	 */
	public void setJudgeTime(Date judgeTime) {
		this.judgeTime = judgeTime;
	}

	public List<DefectJudgeDetail> getDefectJudgeDetails() {
		return defectJudgeDetails;
	}

	public void setDefectJudgeDetails(List<DefectJudgeDetail> defectJudgeDetails) {
		this.defectJudgeDetails = defectJudgeDetails;
	}

	public Float getPlanQty() {
		return planQty;
	}

	public void setPlanQty(Float planQty) {
		this.planQty = planQty;
	}

	public Float getBatchCount() {
		return batchCount;
	}

	public void setBatchCount(Float batchCount) {
		this.batchCount = batchCount;
	}

	public String getCheckBillUids() {
		return checkBillUids;
	}

	public void setCheckBillUids(String checkBillUids) {
		this.checkBillUids = checkBillUids;
	}

	public Boolean getIsBulkReject() {
		return isBulkReject;
	}

	public void setIsBulkReject(Boolean isBulkReject) {
		this.isBulkReject = isBulkReject;
	}

	public String getBulkRejectJudgerName() {
		return bulkRejectJudgerName;
	}

	public void setBulkRejectJudgerName(String bulkRejectJudgerName) {
		this.bulkRejectJudgerName = bulkRejectJudgerName;
	}

	public String getBulkRejectJudgeSignDate() {
		return bulkRejectJudgeSignDate;
	}

	public void setBulkRejectJudgeSignDate(String bulkRejectJudgeSignDate) {
		this.bulkRejectJudgeSignDate = bulkRejectJudgeSignDate;
	}

	public String getBulkRejectJudgeMind() {
		return bulkRejectJudgeMind;
	}

	public void setBulkRejectJudgeMind(String bulkRejectJudgeMind) {
		this.bulkRejectJudgeMind = bulkRejectJudgeMind;
	}

}
